<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<%@ taglib prefix="t" uri="http://myfaces.apache.org/tomahawk"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>ユーザ管理</title>
</head>
<!-- Begin header -->
<jsp:include page="header.jsp"></jsp:include>
<!-- End header -->
<body>
<f:view beforePhase="#{listUserManaged.initPage}">
	<!-- Begin vung dieu kien tim kiem -->
	<h:form id="mainform">
		<h:panelGrid columns="1" styleClass="tbl_input" width="90%"
			cellpadding="0" cellspacing="0">
			<h:outputText value="">
				</br>
			</h:outputText>
			<h:outputText>会員名称で会員を検索します。検索条件無しの場合は全て表示されます。
		</h:outputText>
			<h:panelGrid columns="3" styleClass="tbl_input" cellpadding="4"
				cellspacing="0">
				<%-- The first row: 3 columns --%>
				<h:outputText styleClass="lbl_left" value="氏名:">
				</h:outputText>
				<h:inputText styleClass="txtBox" id="name"
					value="#{listUserManaged.fullName}" size="20"
					onfocus="this.style.borderColor='#0066ff';"
					onblur="this.style.borderColor='#aaaaaa';">
				</h:inputText>
				<h:outputText>
				</h:outputText>
				<%-- The second row: 3 columns--%>
				<h:outputText styleClass="lbl_left" value="グループ:"></h:outputText>
				<h:selectOneMenu value="#{listUserManaged.groupId}">
					<%-- Can be use <h:selectOneListBox size = 1 smt...></h:selectOneListBox>  --%>
					<f:selectItems value="#{listUserManaged.itemGroups}" />
					<%-- save state of comboBox --%>
					<t:saveState value="#{listUserManaged.itemGroups}" />
				</h:selectOneMenu>
				<h:panelGrid columns="2">
					<h:commandButton styleClass="btn" value="検索"
						action="#{listUserManaged.doSearch}" />
					<h:commandButton action="#{userManaged.doRegist}" styleClass="btn btn_wider" value="新規追加"></h:commandButton>
				</h:panelGrid>
			</h:panelGrid>
		</h:panelGrid>
		<div>
		<%-- Table that show TblUser's info --%>
		<h:dataTable
			id="dataTable" value="#{listUserManaged.lsUserDetailDto}" var="item"
			border="1" cellpadding="4" cellspacing="0" width="80%"
			styleClass="tbl_list" headerClass="tr2">
			<%-- Column ID --%>
			<h:column>
				<f:facet name="header">
					<h:outputText value="ID" />
				</f:facet>
				<h:outputText value="#{item.userID}"></h:outputText>
			</h:column>
			<%-- Column fullName --%>
			<h:column>
				<f:facet name="header">
					<h:outputText value="氏名">
						<c:if
							test="${listUserManaged.sortByFullName == NULL || listUserManaged.sortByFullName == 'ASC'}">
							<h:commandLink action="#{listUserManaged.doSort}" value="▲▽">
								<f:param name="sortByFullName"
									value="#{listUserManaged.sortByFullName}" />
								<f:param name="sortType" value="full_name" />
							</h:commandLink>
						</c:if>

						<c:if
							test="${listUserManaged.sortByFullName == NULL || listUserManaged.sortByFullName == 'DESC'}">
							<h:commandLink action="#{listUserManaged.doSort}" value="△▼">
								<f:param name="sortByFullName"
									value="#{listUserManaged.sortByFullName}" />
								<f:param name="sortType" value="full_name" />
							</h:commandLink>
						</c:if>

					</h:outputText>
				</f:facet>
				<h:outputText value="#{item.fullName}"></h:outputText>
			</h:column>
			<%-- Column birthday --%>
			<h:column>
				<f:facet name="header">
					<h:outputText value="生年月日" />
				</f:facet>
				<h:outputText value="#{item.birthday}">
					<f:convertDateTime pattern="yyyy/MM/dd" />
				</h:outputText>
			</h:column>
			<%-- Column groupName --%>
			<h:column>
				<f:facet name="header">
					<h:outputText value="グループ" />
				</f:facet>
				<h:outputText value="#{item.groupName}"></h:outputText>
			</h:column>
			<%-- Column email --%>
			<h:column>
				<f:facet name="header">
					<h:outputText value="メールアドレス" />
				</f:facet>
				<h:outputText value="#{item.userEmail}"></h:outputText>
				<%-- Column userTel --%>
			</h:column>
			<h:column>
				<f:facet name="header">
					<h:outputText value="電話番号" />
				</f:facet>
				<h:outputText value="#{item.userTel}"></h:outputText>
			</h:column>
			<%-- Column nameLevel/ JapanLevel --%>
			<h:column>
				<f:facet name="header">
					<h:outputText value="日本語能力">
						<c:if
							test="${listUserManaged.sortByCodeLevel == NULL ||  listUserManaged.sortByCodeLevel == 'ASC'}">
							<h:commandLink action="#{listUserManaged.doSort}" value="▲▽">
								<f:param name="sortByCodeLevel"
									value="#{listUserManaged.sortByCodeLevel}" />
								<f:param name="sortType" value="code_level" />
							</h:commandLink>
						</c:if>
						<c:if
							test="${listUserManaged.sortByCodeLevel == NULL ||  listUserManaged.sortByCodeLevel == 'DESC'}">
							<h:commandLink action="#{listUserManaged.doSort}" value="△▼">
								<f:param name="sortByCodeLevel"
									value="#{listUserManaged.sortByCodeLevel}" />
								<f:param name="sortType" value="code_level" />
							</h:commandLink>
						</c:if>
					</h:outputText>
				</f:facet>
				<h:outputText value="#{item.nameLevel}"></h:outputText>
			</h:column>
			<%-- Column endDate --%>
			<h:column>
				<f:facet name="header">
					<h:outputText value="失効日">
						<c:if
							test="${listUserManaged.sortByEndDate == NULL ||  listUserManaged.sortByEndDate == 'DESC'}">
							<h:commandLink action="#{listUserManaged.doSort}" value="△▼">
								<f:param name="sortByEndDate"
									value="#{listUserManaged.sortByEndDate}" />
								<f:param name="sortType" value="end_date" />
							</h:commandLink>
						</c:if>
						<c:if
							test="${listUserManaged.sortByEndDate == NULL ||  listUserManaged.sortByEndDate == 'ASC'}">
							<h:commandLink action="#{listUserManaged.doSort}" value="▲▽">
								<f:param name="sortByEndDate"
									value="#{listUserManaged.sortByEndDate}" />
								<f:param name="sortType" value="end_date" />
							</h:commandLink>
						</c:if>
					</h:outputText>
				</f:facet>
				<h:outputText value="#{item.endDate}">
					<f:convertDateTime pattern="yyyy/MM/dd" />
				</h:outputText>
			</h:column>
			<%-- Column total --%>
			<h:column>
				<f:facet name="header">
					<h:outputText value="点数" />
				</f:facet>
				<h:outputText value="#{item.total}"></h:outputText>
			</h:column>
		</h:dataTable>
		</h:form>

		<h:form id="newForm">
		 <%-- This section to show string paging --%>
		 <c:if
			test="${listUserManaged.currentSection > 1}">
			<h:commandLink action="#{listUserManaged.doSearch}" value=""><<
			<f:param
					name="previousSection"
					value="#{listUserManaged.currentSection - 1}" />
			</h:commandLink>
		</c:if> <t:dataList id="pagingDataList" value="#{listUserManaged.strPaging}"
			var="item">
			<f:verbatim>&nbsp;</f:verbatim>
			<h:commandLink value="#{item}" action="#{listUserManaged.doSearch}">
				<f:param name="pageNumber" value="#{item}" />
			</h:commandLink>
			<f:verbatim>&nbsp;</f:verbatim>
		</t:dataList> <c:if
			test="${listUserManaged.strPaging == null || listUserManaged.currentSection < listUserManaged.totalSection}">
			<h:commandLink action="#{listUserManaged.doSearch}" value=">>">
				<f:param name="nextSection"
					value="#{listUserManaged.currentSection + 1}" />
			</h:commandLink>
		</c:if>
		 <%-- This section show message error "Can not find user" --%> <h:messages
			showDetail="true" errorClass="errMsg">
		</h:messages> <h:outputText value="#{listUserManaged.message}">
		</h:outputText></div>
	</h:form>
</f:view>

</body>
<jsp:include page="footer.jsp"></jsp:include>
</html>